widget: Always set the type on css nodes
authorMatthias Clasen <mclasen@redhat.com>
Fri, 23 Oct 2015 01:00:12 +0000 (21:00 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 23 Oct 2015 01:01:06 +0000 (21:01 -0400)
See the previous commit for why this is necessary.

Also make gtk_widget_class_set_css_name work by looking at
the correct class for the name.

Note for future reference: GTK_WIDGET_GET_CLASS() does not
work in the instance init function.

gtk/gtkwidget.c

index 4b1668d29504d4c41d4802942ef789860b4b50f0..e5763df3b01bb48a5a5f4f6033ae2c601fcdfdff 100644 (file)
@@ -4366,10 +4366,9 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
   priv->cssnode = gtk_css_widget_node_new (widget);
   gtk_css_node_set_state (priv->cssnode, GTK_STATE_FLAG_DIR_LTR);
   /* need to set correct type here, and only class has the correct type here */
-  if (GTK_WIDGET_GET_CLASS (widget)->priv->css_name)
-    gtk_css_node_set_name (priv->cssnode, GTK_WIDGET_GET_CLASS (widget)->priv->css_name);
-  else
-    gtk_css_node_set_widget_type (priv->cssnode, G_TYPE_FROM_CLASS (g_class));
+  gtk_css_node_set_widget_type (priv->cssnode, G_TYPE_FROM_CLASS (g_class));
+  if (GTK_WIDGET_CLASS (g_class)->priv->css_name)
+    gtk_css_node_set_name (priv->cssnode, GTK_WIDGET_CLASS (g_class)->priv->css_name);
 
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
   priv->style = gtk_widget_get_default_style ();